package


import com.docu.common.Action
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component

@Component("create${className}Action")
class Create${className}Action extends Action {

  @Autowired
  ${className}Service ${propertyName}Service

  public Object preCondition(Object params, Object object) {
    try {
      ${className} ${propertyName} = (${className}) object
      if (!${propertyName}.validate()) {
        return null
      }
      return ${propertyName}
    } catch (Exception ex) {
    log.error(ex.message)
      return null
    }
  }

  public Object execute(Object params, Object object) {
    try {
      return ${propertyName}Service.create(object)
    } catch (Exception ex) {
    log.error(ex.message)
      return null
    }
  }

  public Object postCondition(Object params, Object object) {
    return null
  }
}